import axios from '@/libs/api.request'

export const getDicTypeTree = info => {
  return axios.request({
    url: 'system/dictionary/type/tree',
    method: 'get',
    data: info
  })
}

export const getDicTree = info => {
  return axios.request({
    url: 'system/get_dic_tree',
    method: 'get',
    data: info
  })
}
/**
 * 保存字典类型
 * @param {*} info 
 */
export const saveDicType = info => {
  return axios.request({
    url: 'system/dictionary/type/save',
    method: 'POST',
    data: info
  })
}
/**
 * 保存字典
 * @param {} data 
 */
export const saveDic = data => {
  return axios.request({
    url: 'system/dictionary/save',
    method: 'POST',
    data
  })
}
/**
 * 保存公司
 * @param {} data 
 */
export const saveCompany = data => {
  return axios.request({
    url: 'system/company/save',
    method: 'POST',
    data
  })
}

/**
 * 删除公司
 * @param {} data 
 */
export const deleteCompany = data => {
  return axios.request({
    url: 'system/company/delete',
    method: 'POST',
    data
  })
}

export const getLogData = (data) => {
  return axios.request({
    url: 'system/log/page',
    method: 'post',
    data
  })
}

export const getUserData = (data) => {
  return axios.request({
    url: 'system/user/page',
    method: 'get',
    params: data
  })
}

export const getCompanyData = (data) => {
  return axios.request({
    url: 'system/company/page',
    method: 'get',
    params: data
  })
}
/**
 * 获取字典数据
 * @param {*} data 
 * @param {*} params 
 */
export const getDicData = (data,params) => {
  var p='';
  if(params){
    p="?="+params
  }
  return axios.request({
    url: 'system/dictionary/page'+p,
    method: 'post',
    data
  })
}

export const getTableData = () => {
  return axios.request({
    url: 'get_table_data',
    method: 'get'
  })
}

export const getAreaTree = () => {
  return axios.request({
    url: 'system/area/tree',
    method: 'get'
  })
}

export const getDragList = () => {
  return axios.request({
    url: 'get_drag_list',
    method: 'get'
  })
}

export const errorReq = () => {
  return axios.request({
    url: 'error_url',
    method: 'post'
  })
}

export const saveErrorLogger = info => {
  return axios.request({
    url: 'save_error_logger',
    data: info,
    method: 'post'
  })
}

export const uploadImg = formData => {
  return axios.request({
    url: 'image/upload',
    data: formData
  })
}

export const getOrgData = () => {
  return axios.request({
    url: 'get_org_data',
    method: 'get'
  })
}

export const getTreeSelectData = () => {
  return axios.request({
    url: 'get_tree_select_data',
    method: 'get'
  })
}
